#include "GY_TreeViewDemo.h"
#include "ui_GY_TreeViewDemo.h"

GY_TreeViewDemo::GY_TreeViewDemo(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::GY_TreeViewDemo)
{
    ui->setupUi(this);
    ui->treeView->setColumnCount(3);

    QVariant a = 0;
    QVariant b = 1;
    QVariant c = 2;
    ui->treeView->addIconType(a,QIcon(":/Resources/res/Dir.png"));
    ui->treeView->addIconType(b,QIcon(":/Resources/res/Assembly.png"));
    ui->treeView->addIconType(c,QIcon(":/Resources/res/Display.png"));

    ui->treeView->addRowData(1,QVector<QVariant>()<<QString("A1")<<QString("A2")<<QString("A3"),0,a);
    ui->treeView->addRowData(2,QVector<QVariant>()<<QString("B1")<<QString("B2")<<QString("B3"),0,a);
    ui->treeView->addRowData(3,QVector<QVariant>()<<QString("C1")<<QString("C2")<<QString("C3"),0,a);
    ui->treeView->addRowData(11,QVector<QVariant>()<<QString("A11")<<QString("A12")<<QString("A13"),1,b);
    ui->treeView->addRowData(12,QVector<QVariant>()<<QString("A21")<<QString("A22")<<QString("A23"),1,b);
    ui->treeView->addRowData(121,QVector<QVariant>()<<QString("A211")<<QString("A212")<<QString("A213"),12,c);
    ui->treeView->insterRowData(21,QVector<QVariant>()<<QString("B11")<<QString("B12"),0,2,b);
    ui->treeView->setNodeIconType(12,c);
}

GY_TreeViewDemo::~GY_TreeViewDemo()
{
    delete ui;
}

void GY_TreeViewDemo::on_pushButton_SetColunm_clicked()
{
    bool  isOK;
    int colunm=ui->lineEdit_SetColunm->text().toInt(&isOK);
    if(isOK)
    {
        ui->treeView->setColumnCount(colunm);
    }
}
